#ifndef VEC3_INCLUDED
#define VEC3_INCLUDED

#pragma once

#include "vec.h"

template <typename T>
union vec<T, 3>
{
	T data[3];
	struct { T x, y, z; };

	vec()
		: x(T()), y(T()), z(T())
	{
	}

	vec(const vec& rhs)
		: x(rhs.x), y(rhs.y), z(rhs.z)
	{
	}

	vec(T _x, T _y, T _z)
		: x(_x), y(_y), z(_z)
	{
	}
};

template <typename Type>
vec<Type, 3> CrossProduct(const vec<Type, 3>& a, const vec<Type, 3>& b)
{
	vec<Type, 3> result;
	result.x = a.y * b.z - a.z * b.y;
	result.y = a.z * b.x - a.x * b.z;
	result.z = a.x * b.y - a.y * b.x;
	return result;
}

typedef vec<float, 3> vec3f;
typedef vec<double, 3> vec3d;

#endif